var IMconn = null ;
var homeis = true;

var share_desc = '',share_title = '',share_img = '';
//_RT = null;
	//首页
	var home = {
		pageShow: function() {
			if(homeis){
				homeis = false;
				pageFun.homegetdata();
			}
			bindFunction();
			pageFun.home();
		},
		pageBeforeShow:function(){
			pageFun.homegetdata();
		}
	};
	
	// 签到页面
	var tpl_SignPage = {
		pageShow: function() {
			bindFunction();
			$('.ProductList li').unbind('tap').on('tap',function(){
				var type = $(this).attr('type');
				viewApi.go('#tpl_ProductPage',type);
			})
		},
		pageBeforeShow:function(){
			Api.post(Api.sign_in_prizes,{},function(obj){
				var goods = obj.d.goods_list;
				var html = '';
				$.each(goods,function(i,d){
					html += '<li type="'+d.id+'"><i class="photo" style="background-image:url('+d.list_img+')"></i><span class="title">'+d.title+'</span><span class="number">签到'+d.sign_in_num+'次就是你的了</span></li>';
				});
				$(".SignPageMain .ProductList").html(html);
				
				var UserName = obj.d.record;
				var UserNameHtml = '';
				$.each(UserName,function(i,d){
					UserNameHtml += '<li>恭喜用户名为'+d.nickname+'获得'+d.title+'！</li>';
				});
				$('.SignPageMain .UserList').html(UserNameHtml);
				
			})
		}
	};
	
	// 签到完成
	var tpl_SignSuccess = {
		pageShow: function(){
			bindFunction();
		},
		pageBeforeShow:function(){
			var parm = viewApi.parms;
			Api.post(Api.award_page,{id:parm[0]},function(obj){
				if(obj.s){
					console.log(obj)
					$('.SignSuccess .SignImgBox b').css('background-image','url('+obj.d.img+')');
					if(obj.d.status == 1){
						$('.InputBox .ExpressBlock').hide();
						$('.InputBox .InputBlock').show();
					}else{
						$('.kuaidi').val(obj.d.express);
						$('.danhao').val(obj.d.express_number);
						$('.InputBox .ExpressBlock').show();
						$('.InputBox .InputBlock').hide();
					}
				}
			});
			
			$('.InputBlock button').unbind('tap').on('tap',function(){
				var name = $('.name').val();
				var phone = $('.phone').val();
				var address = $('.address').val();
				var te = /^1[3|4|5|8][0-9]\d{4,8}$/;
				if(name && phone && address){					
					if(te.test(phone)){
						Api.post(Api.award_address,{id:parm[0],user_name:name,mobile:phone,address:address},function(obj){
							if(obj.s){
								$('.InputBox .ExpressBlock').show();
								$('.InputBox .InputBlock').hide();
								$('.ExpressBlock').find('.kuaidi,.danhao').val('暂无数据');
								mui.toast('提交成功，请等待发货');
							}
						});					
					}else{
						mui.toast('请输入正确的手机号');
					}
				}else{
					mui.toast('请输入完整信息');
				}
			});
			
		}
	};
	
	// 签到成功
	var tpl_ProductPage2 = {
		pageBeforeShow:function(){
			var hhh = $(window).height() - $('.ProductImg').height() - $('.ProductName').height() - $('.ProductFooter').height() - $('.header_1').height() - 38;
			$('.ProductDetail').height(hhh);
			$('.ProductDetail pre.Content').height(hhh - 55);
			var parm = viewApi.parms;
			Api.post(Api.sign_in_page,{id:parm[0]},function(obj){
				if(obj.s){
					console.log(obj);
					share_desc = obj.d.info.share_desc;
					share_title = obj.d.info.share_title;
					share_img = obj.d.info.list_img;
					$('.ProductPageHead2 h2').text(obj.d.info.title);
					pageFun.tpl_ProductPage2(share_title,share_desc,share_img,parm);
					var log = obj.d.log;
					var dom =  $('.ProductPageMain2');
					$(dom).find('pre.Content').html(obj.d.info.content);
					$(dom).find('.ProductName').attr('type',obj.d.info.id);
					$(dom).find('.ProductName p').eq(0).text(obj.d.info.title);
					$(dom).find('.ProductName p').eq(1).text('签到'+obj.d.info.sign_in_num+'次就是你的了');
					$(dom).find('.ProductName span').text('已签到'+obj.d.num+'次');
					var html = '';
					$.each(log,function(i,d){
						html += '<li><i class="img" style="background-image:url('+d.img+')"></i><span class="txt">'+d.nickname+'</span><span class="time">'+d.time+'</span></li>';
					});
					$('.ProductPageMain2 .UserList').html(html);
					
					if(obj.d.lingqv == 1){
						$('.ProductPageMain2 .SignBtn').addClass('buttonSta');
						duihuan();
					}else{
						$('.ProductPageMain2 .SignBtn').removeClass('buttonSta');
					}
				}
			});
			function duihuan(){
				$('.ProductPageMain2 .buttonSta').unbind('tap').on('tap',function(){
					var id = $(this).parent().attr('type');
					viewApi.go('#tpl_SignSuccess',id);
				});
			}
		},
		pageShow: function() {
			bindFunction(); 

		}
	}
	
	// 签到产品详情
	var tpl_ProductPage = {
		pageShow: function() {
			bindFunction();
			$('.SignBtn2').unbind('tap').on("tap",function(){
				var id = $(this).parent().attr('type');
				Api.post(Api.prizes_sign_in,{type:1,id:id},function(obj){
//					if(obj.s){
						viewApi.go('#tpl_ProductPage2',id);
						console.log(obj);
//					};
				});
			});

		},
		pageBeforeShow:function(){
			var parm = viewApi.parms;
			Api.post(Api.prizes_detail,{id:parm[0]},function(obj){
				console.log(obj);
				if(obj.s){
					if(obj.d.ad){
						$('.ProductFooter img').attr({'src':obj.d.ad.img,'link':obj.d.ad.link});
					}else{
						$('.ProductFooter').hide();
					}
					
					$('.ProductPageHead h2').text(obj.d.info.title);
					
					$('.ProductImg i.Img').css('background-image','url('+obj.d.info.img+')');						
					$('pre.Content').html(obj.d.info.content);
					$('.ProductName').attr('type',obj.d.info.id);
					$('.ProductName p').eq(0).text(obj.d.info.title)
					$('.ProductName p').eq(1).text('签到'+obj.d.info.sign_in_num+'次就是你的了');
				}
				
			});
			var hhh = $(window).height() - $('.ProductImg').height() - $('.ProductName').height() - $('.ProductFooter').height() - $('.header_1').height() - 38;
			$('.ProductDetail').height(hhh);
			
			$('.ProductDetail pre.Content').height(hhh - 55)
		}
	};
	
	// 首页轮播详情
	var tpl_HomeBannerDetails = { 
		pageShow: function() {
			bindFunction(); 
			pageFun.tpl_HomeBannerDetails();
		},
		pageBeforeShow:function(){
			$('.HomeBannerDetailsHead h2').text('');
			$('.HomeBannerDetails').html('<pre class="HomeBannerDetailsBox"></pre>');
		}
	};
	
	// 品牌列表
	var tpl_MoreBrands = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_MoreBrands();
		}
	};
	
	// 头条列表
	var tpl_NewsList = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_NewsList();
		}
	};
	
	// 直播
	var tpl_BeautyLive = {
		pageShow: function() {
			bindFunction(); 
			pageFun.tpl_BeautyLive();
		}
	};
	// 免费打牌
	var tpl_Admission = {
		pageBeforeShow:function(){
			$(".S_M_M_header.YuYue_uptab").css('top',$('.BrandHed').height()+$(".BrandPosition").height()+11);
			$(".BrandPosition").css("top",$(".BrandHed").height());
			$(".BrandMain").css('cssText','padding-top:2.18rem !important');
		},
		pageShow: function() {
			bindFunction(); 
			pageFun.tpl_Admission();
		}
	};
	// 品牌详情
	var tpl_DealerStore2 = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_DealerStore2();
		},
		pageBeforeShow:function(){
			$('.Product pre').empty();
			$('#DealerStore .mui-slider-group').empty();
			var parm = viewApi.parms;
			Api.post(Api.brand_detail,{id:parm[0]},function(obj){
				if(obj.s){
					$('.ProductName p').html(obj.d.product_name + '<span class="iconfont icon-zan">点赞'+obj.d.thumbs_up+'</span>');
					$('.Product pre').html(obj.d.content);
					$('#DealerStore2Head h2').text(obj.d.brand_name);
					var html = '';
					var html2 = '';
					$.each(obj.d.imgs,function(i,d){
						html += '<div class="mui-slider-item"><img src="'+d+'"></div>';
					});
					var num = obj.d.imgs.length;
					for(var e = 1;e <= num;e++){
						html2 += '<div class="mui-indicator"></div>';
					};
					$('.mui-slider-group').html(html);
					$('.mui-slider-indicator').html(html2);
					$('.mui-slider-indicator .mui-indicator').eq(0).addClass('mui-active');
					czan();
				}else{
					mui.toast(obj.m);
				}
			});
			function czan(){
				$('.ProductName .icon-zan').unbind('tap').on('tap',function(){
					Api.post(Api.thumbs_up,{id:parm[0]},function(obj){
						if(obj.s){
							$('.ProductName .icon-zan').text("点赞" + obj.d.thumbs_up);
							mui.toast(obj.m);
						}else{
							if(obj.m == 'Token does not exist,Please login'){
								mui.toast('请先登录');
							}else{
								mui.toast(obj.m);								
							}
						}
					})
				});
			}
		}
	}
	
	// 经销商店铺
	var tpl_DealerStore = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_DealerStore();
		}
	}
	
	//
	var tpl_nearby_shop_goods = {
		pageBeforeShow:function(){
			var parm = viewApi.parms;
			Api.post(Api.nearby_shop_goods,{id:parm[0]},function(obj){
				if(obj.s){
					$('main.nearby_shop_goods pre').html(obj.d.content);
					$('.left img').attr('src',obj.d.wechat_pay_qr);
					$('.right img').attr('src',obj.d.alipay_qr);
					
				}else{
					mui.toast(obj.m);
				}
			});
		},
		pageShow: function() {
			bindFunction();
			pageFun.tpl_nearby_shop_goods();
		}
	}
	
	var tpl_PopApply = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_PopApply();
		}
	}
	
	//棋牌室列表
	var brand = {
		pageBeforeShow:function(){
			$(".S_M_M_header.YuYue_uptab").css('top',$('#brandHeader').height()+$("#brandMainPosition").height()+11);
			$("#brandMainPosition").css("top",$("#brandHeader").height());
			$("#brandMain").css('cssText','padding-top:2.18rem !important');
		},
		pageShow: function() {
			bindFunction();
			pageFun.brand();  
		}
	};
	//麻将馆详情
	var tpl_shop = {
		pageShow: function() {
			bindFunction();
			pageFun.shop();
			$('.mui-dtpicker').remove();
		},
		pageBeforeBack:function(){
			$('.mui-dtpicker').remove();
		}
	};
	// 维修详情
	var tpl_RepairListInfo = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_RepairListInfo();
			$('.mui-dtpicker').remove();
		},
		pageBeforeBack:function(){
			$('.mui-dtpicker').remove();
		}
	};
	//资讯
	var tpl_information = {
		pageBeforeShow:function(){
			
		},
		pageShow: function() {
			bindFunction();
			pageFun.information();  
		},
		pageBeforeBack:function(){
			$('#information_container').empty();
		}
	};
	
	//申请加盟
	var tpl_A_T_J = {
		pageShow: function(){
			bindFunction();
			pageFun.A_T_J();
		}
	};
	
	//报修
	var near_Repair = {
		pageBeforeShow:function(){
//			$(".S_M_M_header.YuYue_uptab").css('top',$('.BrandHed').height() + $(".BrandPosition").height() + 11);
//			$(".BrandPosition").css("top",$(".BrandHed").height());
//			$(".BrandMain").css('cssText','padding-top:2.18rem !important');
//			
//			var lng = fun.getCache("lng");
//			var lat = fun.getCache("lat");
//			var ace = fun.getCache('ace');
//			pageFun.RepairGetListData(lat,lng,ace);
		},
		pageShow: function(){
			bindFunction();
			pageFun.Repair();
		}
	};
	
	//社区
	var community = { 
		pageShow: function() { 
			bindFunction();
			pageFun.Community(); 
			var deceleration = mui.os.ios?0.003:0.0009;
			$('.mui-scroll-wrapper').scroll({
					bounce: false,
					indicators: true, //是否显示滚动条
					deceleration:deceleration
			});
			$('.Community-tab .border-btm').click();
			
		}
	};
	
	//板块专区
	var tpl_bkl = {
		pageShow: function() {
			bindFunction();
			pageFun.bk();
		} 
	};
	//帖子详情
	var tpl_T_Z1 = {
		pageShow: function() {
			bindFunction();
			pageFun.T_Z1();
		}
	};
	
	//发帖
	var tpl_Post = {
		pageShow: function() {
			bindFunction();
			pageFun.Post();
		}
	};
	
	//商城首页
	var tpl_Mall_home = {
		pageShow: function() {
			bindFunction();
			$(".MallHome").css({"margin-top":$(".pHead").height(),'margin-bottom':$(".footer0").height()});
			$(".MallHome").height($(window).height()-$('.pHead').height()-$(".footer0").height());
			pageFun.Mall_home();
			$(".footer0").show();
		}
	};
	//商城 
	var tpl_Shopping_Mall = {
		pageShow: function() {
			bindFunction();
			pageFun.Shopping_Mall();  
		}
	};
	//商品详情
	var tpl_Product_Details = {
		pageShow: function() {
			bindFunction(); 
			pageFun.Product_Details();
		},
		pageBeforeBack:function(){
			$('.PD_swiper,.PDMSwiper').empty();
		}
	};
	
	//设置
	var tpl_Set_Up ={
		pageShow: function() {
			bindFunction();
			pageFun.Set_Up();
		}
	};
	
	//关于我们
	var tpl_About_us = {
		pageShow: function() {
			bindFunction();
			pageFun.About_us();
		}
	};
	
	//软件介绍
	var tpl_About_us2 = {
		pageShow: function() {
			bindFunction();
			pageFun.About_us2();
		}
	};
	
	//客服留言 
	var tpl_Z_X_KF = {
		pageShow: function() {
			bindFunction();
			pageFun.Z_X_KF();
		}
	};
	//我的
	var tpl_My = {
		pageBeforeShow:function(){
			
		},
		pageShow: function() {
			bindFunction();
			pageFun.My();
		}
	};
	// 维修工申请
	var tpl_RepairApply = {
		pageBeforeShow:function(){
			
		},
		pageShow: function() {
			bindFunction();
			pageFun.tpl_RepairApply();
		}
	}
	// 品牌入驻 
	var tpl_BrandSettled = {
		pageBeforeShow:function(){
			
		},
		pageShow: function() {
			bindFunction();
			pageFun.tpl_BrandSettled();
		}
	}
	
	//地址管理
	var tpl_Address = {
		pageShow: function() {
			bindFunction();
			pageFun.Address();
		}
	};
	
	//地址编辑 tpl_EditAddress
	var tpl_EditAddress = {
		pageShow: function() {
			bindFunction();
			pageFun.EditAddress();
		}
	};
	
	//添加地址 tpl_addressadd
	var tpl_addressadd = {
		pageShow: function() {
			bindFunction();
			pageFun.addressadd();
		}
	};
	
	//我的棋牌室
	var tpl_My_Chess1 = {
		pageShow: function() {
			bindFunction();
			pageFun.My_Chess1();
		}
	};
	
	//预约订单
	var tpl_Order2 = {
		pageShow: function() {
			bindFunction();
			pageFun.Order2();
		}
	};
	
	//我的评价
	var tpl_My_evaluate ={
		pageShow: function(){
			bindFunction();
			pageFun.My_evaluate();
		}
	};
	
	//店铺维护
	var tpl_Maintain = {
		pageShow: function(){
			bindFunction();
			pageFun.Maintain();
		}
	};
	
	//预约订单
	var tpl_Order1 = {
		pageShow: function() {
			bindFunction();
			pageFun.Order1();
		}
	};
	
	//我的订单 
	var tpl_OrderDetails = {
		pageShow: function() {
			bindFunction();
			pageFun.OrderDetails();
		}
	};
	
	//待付款
	var tpl_FuKuan = {
		pageShow: function() {
			bindFunction();
			pageFun.FuKuan();
		}
	};
	
	//待发货
	var tpl_FaHuo = {
		pageShow: function() {
			bindFunction();
			pageFun.FaHuo();
		}
	};
	
	//待评价
	var tpl_YuYue = {
		pageShow: function() {
			bindFunction();
			pageFun.YuYue();
		}
	};
	
	//待收货
	var tpl_ShouHuo = {
		pageShow: function() {
			bindFunction();
			pageFun.ShouHuo();
		}
	};
	
	//评价 
	var tpl_Comment = {
		pageShow: function() {
			bindFunction();
			pageFun.Comment();
		}
	};
	
	//商品评价 
	var tpl_Comment2 = {
		pageShow: function() {
			bindFunction();
			pageFun.Comment2();
		}
	};
	//我的订单
	var tpl_My_Order = {
		pageShow: function() {
			bindFunction();
			pageFun.My_Order();
		}
	};
	//个人信息
	var tpl_Personal = {
		pageShow: function() {
			bindFunction();
			pageFun.Personal();
			pageFun.user();
		}
	};
	
	//申请入驻 
	var tpl_Settled = {
		pageShow: function() {
			bindFunction();
			pageFun.Settled();
		}
	};
	
	// 附近麻将机店 入驻 
	var tpl_Settled2 = {
		pageShow: function() {
			bindFunction();
			pageFun.Settled2();
		}
	};
	
	//联系人
	var tpl_Contacts = {
		pageShow: function() {
			bindFunction();
			pageFun.Contacts();
		}
	};

	//发送消息 单聊 
	var tpl_FS_XX = {
		pageShow: function() {
			bindFunction();
			pageFun.FS_XX();
		}
	};
	
	//发送消息 群聊 
	var tpl_Group_chat = {
		pageShow: function() {
			bindFunction();
			pageFun.Group_text();
		},
		pageBeforeBack: function(){
			$('#main').html("");
		}
	};
	
	//群聊邀请 
	var tpl_GroupChat = {
		pageBeforeShow:function(){
			$("#ChatContant").hide();
		},
		pageShow: function() {
			bindFunction();
			pageFun.GroupChat();
		}
	};
	//群资料
	var tpl_Chat = {
		pageBeforeShow:function(){
			$("#ChatContant").show();
			$("#Chat_main").css("margin-top",$('#ChatContant').height());
		},
		pageShow: function() {
			bindFunction();
			pageFun.Chat();
		},
		pageBeforeBack: function(){
			$("#ChatContant").hide();
			$("#Add_this").empty();
		}
	};
	
	//群管理 
	var tpl_qun = {
		pageShow: function() {
			bindFunction();
			pageFun.qun();
		}
	};
	
	//群组 
	var tpl_Group = {
		pageShow: function() {
			bindFunction();
			pageFun.Group();
		}
	};
	//添加好友
	var tpl_ADD = {
		pageShow: function() {
			bindFunction();
			pageFun.ADD();
		}
	};
	
	//搜索群组
	var tpl_ADD_Group = {
		pageShow:function(){
			bindFunction();
			pageFun.ADD_Group();
		}
	};
	
	//创建群组
	var tpl_CreateGroup = {
		pageBeforeShow:function(){
			$("#CreateGroup_name .content").text("");
			$(".xuzhi textarea").val("");
			$("#CreateGroup_header").hide();
		},
		pageShow:function(){
			bindFunction();
			pageFun.CreateGroup();
		}
	};
	//消息
	var tpl_My_news = {
		pageShow: function() {
			bindFunction();
			pageFun.My_news();
		}
	}
	
	//购物车
	var Shopping_Cart_page  = {
		pageShow: function() {
			bindFunction();
			pageFun.Shopping_Cart(); 
		}
	};
	
	//确认订单
	var tpl_Confirm_Order = {
		pageShow: function() {
			bindFunction(); 
			pageFun.Confirm_Order(); 
		},
		pageBeforeBack:function(){
			viewApi.parms = []; 
		}
	};
	
	//web视图窗口
	var tpl_webview = {
		pageShow: function() {
			bindFunction();
			pageFun.webview(); 
		}
	};
	
	// 生成地图 
	var tpl_gpsmap = {
		pageShow: function() {
			bindFunction();
			pageFun.gpsmap(); 
		}
	};
	mui.init({
	    swipeBack:false //关闭-右滑关闭功能  
	});  
 	var viewApi = mui('#app').view({
		defaultPage: '#home'
	});
	var view = viewApi.view;
	var first = 0;
	(function(M) {
		//处理view的后退与webview后退
		var oldBack = M.back;
		M.back = function() {
			var ClickPage	= '-tpl_My-home-community-tpl_Mall_home-Shopping_Cart_page';
			//$.inArray(value, array) 
//			console.log(view.currentPageId);
//			if(ClickPage.indexOf(view.currentPageId)>0){
//				if (!first) {
//	                first = new Date().getTime();
//	                mui.toast('再按一次退出应用');
//	                setTimeout(function() {
//	                    first = null;
//	                }, 1000);
//	            } else {
//	                if (new Date().getTime() - first < 2000) {
//	                    plus.runtime.quit();
//	                }
//	            }
//				return false;
//			}
			//如果有弹出页面则先关闭弹出页面
			var Is_token = fun.getCache('token');
			var YDy = fun.getCache("C");
			function nidianbuliao(){				
				$('body').find('.blocknidianbuliao').remove();
				$('body').append('<block class="blocknidianbuliao"></block>');
				$('.blocknidianbuliao').unbind('tap').on('tap',function(e){
					$('#tpl_Land').addClass('popPageShow');
					$(this).remove();
					reg();
				});
			}
			function reg(){
				$('#LandBack').unbind('tap').on("tap",function(){
					$('#tpl_Land').removeClass('popPageShow');
					$('body').append('<block class="blocknidianbuliao"></block>');
					nidianbuliao();
				});
			}
			
			if(!Is_token && YDy){
				$('#tpl_Land').removeClass('popPageShow');
				$('body').append('<block class="blocknidianbuliao"></block>');
				nidianbuliao();
			}else{
				$('body').find('.blocknidianbuliao').remove();
				if($('.popPageShow').length>0){
					$('.popPageShow').removeClass('popPageShow');
				}else if(ClickPage.indexOf(view.currentPageId)>0){
					if (!first) {
		                first = new Date().getTime();
		                mui.toast('再按一次退出应用');
		                setTimeout(function() {
		                    first = null;
		                }, 1000);
		            } else {
		                if (new Date().getTime() - first < 2000) {
		                    plus.runtime.quit();
		                }
		            }
					return false;
				}else if (viewApi.canBack()) { //如果view可以后退，则执行view的后退
					viewApi.back();
				}else { //执行webview后退
					oldBack();
				}
			}
		};
		//注册页面显示的回调函数
		var viewCallBacks = ['pageBeforeShow','pageShow','pageBeforeBack','pageBack'];
		$.each(viewCallBacks, function(i,callback) {
			view.addEventListener(callback, function(e) {
				var fn = null;
				eval( ' fn = ' + e.detail.page.id+'.'+callback);
				if(typeof(fn) == 'function'){ fn();}
				view.currentPageId = e.detail.page.id;//如果点两次退出   调用此   currentPageID
				console.log(e.detail.page.id + ' '+callback);
				console.log('[Parm]：'+viewApi.parms);
			});
		});
		pageFun.initPage();
	})(mui); 
	
	home.pageShow();
	clearBug();
/***
 * 初始化全局的事件绑定
 */
function bindFunction() {
	pageFun.onepage();
	//进入隐藏
	var pageID = view.currentPageId;
	if(pageID != 'home' && pageID != 'community' && pageID != 'tpl_Mall_home' && pageID != 'Shopping_Cart_page' && pageID != 'tpl_My'){
		$(".footer0,.footer9,.G_W_C_Eject,.rgba,.rgba2,.update,.bk,.C_O_E,.Age,.GX,.Gender,#My-Maintain,#SR_input,.android-ics,.tan3,#bq,#MyUserLogin").hide();
	}else{
		$(".footer9,.G_W_C_Eject,.rgba,.rgba2,.update,.bk,.C_O_E,.Age,.GX,.Gender,#My-Maintain,#SR_input,.android-ics,.tan3,#bq,#MyUserLogin").hide();
	}
	
	//进入页面跳转最上
	$('body').scrollTop(0);
	
	pageFun.ios_window('#fff','UIStatusBarStyleDefault')
	$(".footer9 a,.footer0 a").click(function(){
		$(".footer9 a,.footer0 a").css("color","#000");
		$(this).css("color","#ff5000");
	});
	$(".footer li a p").css("color","#000");
	$(".footer9 li a p").css("color","#000");
	fun.bindOnce('.icon-zuojiantou','tap',function(){
		viewApi.back();		
	})
//	$("header .icon-zuojiantou").unbind('click').click(function(){
//		history.go(-1);
//		window.history.back();
//	});
	//弹出隐藏
	$(".icon-guanbi,.rgba").click(function(){
		$(".Eject").hide();
	});
	
	//删除上传图片按钮
	$(".remove").click(function(){
		$(this).parent(".tu").remove();
	});

	//滑块效果
	$(".btn2").click(function(){
		if($(this).hasClass("left")){
			$(this).removeClass("left");
			$(this).addClass("right");
			$(this).parent(".SetUp-btn").css("background-color","#FF5000")
		}else{
			$(this).removeClass("right");
			$(this).addClass("left");
			$(this).parent(".SetUp-btn").css("background-color","#bbb")
		}
	});
	//个人心中js
	$(".li3").click(function(){
		$(".Gender,.rgba").show();
	});
	$(".Gender ul li input").click(function(){
		$("input").removeClass("input2");
		$(this).addClass("input2");
	});
	$(".qx").click(function(){
		$(this).parents(".G_fixed").hide();
		$(".rgba").hide();
	});
	$(".li4").click(function(){
		$(".GX,.rgba").show();
		pageFun.user();
		$('.GX textarea').text(Y.sig);
	});

	$(".age_x").click(function(){
		$(".Age,.rgba").hide();
	});


    //tab切换
    $(".S_M_M_header li").click(function(){
		$(".S_M_M_header li").removeClass("border-btm");
		$(this).addClass("border-btm");
	});
}

/***
 * 处理输入框被弹出键盘遮挡的问题
 */
function clearBug() {
	if(/Android/gi.test(navigator.userAgent)) {
		window.addEventListener('resize', function() {
			if(document.activeElement.tagName == 'INPUT' || document.activeElement.tagName == 'TEXTAREA') {
				window.setTimeout(function() {
					document.activeElement.scrollIntoViewIfNeeded();
				}, 0);
			}
		})
	}
}